var SetOtherOrderDept = function () {
  var template = /*html*/ `
    <div class="setOtherOrderDeptClass" style="padding:0 10px 10px;" v-loading.fullscreen.lock="loading">
      <el-checkbox-group v-model="checkedDepts">
        <el-checkbox v-for="dept in productionDeptList" :label="dept.id" :key="dept.id">{{dept.deptName}}</el-checkbox>
      </el-checkbox-group>
      <div style="margin-top:30px;text-align:center;">
        <el-button type="primary" size="small" @click="addOtherOrderDept">保存</el-button>
        <el-button size="small"  @click="cancel">取消</el-button>
      </div>
    </div>
  `;
  return {
    data: function () {
      return {
        loading: false,
        productionDeptList: [],
        checkedDepts: []
      }
    },
    created: function () {
      this.showOtherOrderDept();
    },
    methods: {
      //设置订单外报工部门
      showOtherOrderDept: function () {
        var self = this;
        this.loading = true;
        ajaxRequest("basicData/getProductionDepartment").then(function (res) {
          self.productionDeptList = res;
          self.loading = false;
        }).catch(function () {
          self.loading = false;
        });
      },
      addOtherOrderDept: function () {
        var productionDeptList = this.checkedDepts;
        if (productionDeptList.length < 1) {
          this.$alert("请勾选部门", "信息");
          return;
        }
        var postData = {
          "deptArray": JSON.stringify(productionDeptList)
        }
        var self = this;
        this.loading = true;
        ajaxRequest("order/addOtherDept", postData).then(function (res) {
          self.loading = false;
          self.$alert(res, "信息");
          self.cancel();
        }).catch(function () {
          self.loading = false;
        });
      },
      //取消
      cancel: function () {
        this.$emit("cancel");
      }
    },
    template: template
  }
}();